﻿using ConfExpert.Forms.Base;
using DevTeam;

using System;
namespace ConfExpert.Forms.Depo
{
    public partial class DepoGirisRaporu : XForm
    {
        public DepoGirisRaporu()
        {
            InitializeComponent();
        }

        private void DepoGirisRaporu_Load(object sender, EventArgs e)
        {

            deBitis.EditValue = DateTime.Now;
            deBaslangic.EditValue = DateTime.Now.AddDays(-7);
            gleBrand.Edit.Assign(RI(Rp.Brand));
            gleVendor.Edit.Assign(RI(Rp.Vendor));
            // gleBrand.BorderStyle = gleVendor.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;

            gvArticle.Init("GetDepoGiris2", deBaslangic.EditValue.ToDate(), deBitis.EditValue.ToDate(), 0, 0);
            gvArticle.AddDetailGrid(gvRoll, "ProductId");
            gvArticle.SetCaptions("UreticiKodu:Üretici Kodu", "MusteriKodu:Müşteri Kodu", "ToplamIlkQty:Toplam Giriş Miktar");
            gvArticle.AddSummary("ToplamIlkQty", "TopAdedi");
            gvArticle.FormatAsNumber(1, "ToplamIlkQty");

            gvRoll.SetCaptions("IlkQty:Giriş Miktarı", "SuankiQty:Mevcut Miktar", "KompozisyonId:Kompozisyon", "GelisTarihi:Geliş Tarihi", "PONr:PO#", "OrderRef:OrderRef.");
            gvRoll.FormatAsNumber(1, "IlkQty", "SuankiQty");
            gvRoll.AddSummary("IlkQty", "SuankiQty");

            gvArticle.MakeReadOnly();
            gvRoll.MakeReadOnly();
            splitContainerControl1.AutoSize();
            btnRapor.ItemClick += btnRapor_ItemClick;
            splitContainerControl1.AutoSize();
        }

        void btnRapor_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gvArticle.RefreshDataSource("GetDepoGiris2", deBaslangic.EditValue.ToDate(), deBitis.EditValue.ToDate(), intParse(gleBrand.EditValue), intParse(gleVendor.EditValue));
            gvRoll.BestFitColumns();
        }
    }
}
